const { DataTypes } = require('sequelize');
const sequelize = require('../../config/db');

const User = sequelize.define('user', {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  username: { type: DataTypes.STRING, allowNull: false, unique: true },
  password: { type: DataTypes.STRING, allowNull: false },
  openid: { type: DataTypes.STRING, allowNull: true, unique: true },
  address: { type: DataTypes.STRING },
  contact: { type: DataTypes.STRING },
  user_type: { type: DataTypes.INTEGER, defaultValue: 1 },
  role: { type: DataTypes.STRING, defaultValue: 'user' },
  created_at: { type: DataTypes.DATE, defaultValue: DataTypes.NOW }
}, {
  tableName: 'user',
  timestamps: false
});

module.exports = User;
